package com.ytjj.qmyx.admin.controller;

import com.ytjj.common.api.CommonResult;
import com.ytjj.qmyx.admin.annotation.OperLog;
import com.ytjj.qmyx.admin.constants.SysLogConstants;
import com.ytjj.qmyx.admin.eunm.GroupEnums;
import com.ytjj.qmyx.admin.model.request.GroupDetailsReq;
import com.ytjj.qmyx.admin.model.request.GroupOrderReq;
import com.ytjj.qmyx.admin.model.response.GroupOrderResp;
import com.ytjj.qmyx.admin.service.GroupDetailsService;
import com.ytjj.qmyx.admin.utils.EmptyUtil;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 *
 * 
 * 拼团详情
 */
@RestController
@AllArgsConstructor
@RequestMapping("/groupDetails")
public class GroupDetailsController {

    private GroupDetailsService groupDetailsService;

    @PostMapping("/selectGroupList")
    @OperLog(operModule = "拼团详情", operDesc = "拼团列表", operType = SysLogConstants.OPERATION_SELECT)
    public CommonResult selectGroupList(@RequestBody GroupDetailsReq groupDetailsReq) {
        return CommonResult.success(groupDetailsService.selectGroupList(groupDetailsReq));
    }

    @GetMapping("/detailGroupList")
    @OperLog(operModule = "拼团详情", operDesc = "拼团详情", operType = SysLogConstants.OPERATION_SELECT)
    public CommonResult detailGroupList(Integer groupId){
        if (EmptyUtil.isEmpty(groupId)) {
            return CommonResult.failed(GroupEnums.PT_IS_NULL.getMessage());
        }
        return CommonResult.success(groupDetailsService.detailById(groupId));
    }

    @PostMapping("/getGroupOrder")
    @OperLog(operModule = "拼团订单", operDesc = "拼团订单", operType = SysLogConstants.OPERATION_SELECT)
    public CommonResult getGroupOrder(@RequestBody GroupOrderReq req){
        return CommonResult.success(groupDetailsService.getGroupOrder(req));
    }
}
